package com.xs.project.controller;

import com.xs.project.common.Result;
import com.xs.project.pojo.vo.CourseResourceRequest;
import com.xs.project.pojo.vo.StuDeviceVo;
import com.xs.project.pojo.vo.StudentDeviceRequest;
import com.xs.project.pojo.vo.StudentHomeWorkReq;
import com.xs.project.pojo.vo.resp.CourseResourceResp;
import com.xs.project.pojo.vo.resp.StudentCourseDeviceResp;
import com.xs.project.pojo.vo.resp.StudentHomeWork;
import com.xs.project.service.ICourseResourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 等风来
 * @since 2024-08-13
 */
@RestController
@RequestMapping("/courseResource")
@Api(tags = "课程资源管理")
public class CourseResourceController {
    @Resource
    private ICourseResourceService courseResourceService;

    @ApiOperation(value = "课程资源-列表", notes = "课程资源")
    @PostMapping(value = "/selectResourceList")
    public Result<List<CourseResourceResp>> selectResourceList(@RequestBody CourseResourceRequest request) {
        return courseResourceService.selectResourceList(request);
    }

    @ApiOperation(value = "课程资源-更新", notes = "课程资源")
    @PostMapping(value = "/updateResourceList")
    public Result<Boolean> updateResourceList(@RequestBody CourseResourceResp request) {
        return Result.success(courseResourceService.updateResourceList(request));
    }

    @ApiOperation(value = "课程资源-新增", notes = "课程资源")
    @PostMapping(value = "/insertResourceList")
    public Result<Boolean> insertResourceList(@RequestBody CourseResourceResp request) {
        return Result.success(courseResourceService.insertResourceList(request));
    }

    @ApiOperation(value = "学生意见-列表", notes = "学生意见")
    @PostMapping(value = "/selectDeviceList")
    public Result<List<StudentCourseDeviceResp>> selectDeviceList(@RequestBody  StudentDeviceRequest request) {
        return courseResourceService.selectStudentDevices(request);
    }

    @ApiOperation(value = "学生意见-新增", notes = "学生意见")
    @PostMapping(value = "/insertDeviceList")
    public Result<Boolean> insertDeviceList(@RequestBody StuDeviceVo request) {
        return Result.success(courseResourceService.insertDeviceList(request));
    }

    @ApiOperation(value = "学生意见-处理", notes = "学生意见")
    @GetMapping(value = "/handleDeviceList")
    public Result<Boolean> handleDeviceList(Integer id, String teacherDesc) {
        return Result.success(courseResourceService.handleDeviceList(id,teacherDesc));
    }

    @ApiOperation(value = "学生作业-列表", notes = "学生作业")
    @PostMapping(value = "/selectStudentHomeWork")
    public Result<List<StudentHomeWork>> selectStudentHomeWork(@RequestBody StudentHomeWorkReq request) {
        return courseResourceService.selectStudentHomeWork(request);
    }

    @ApiOperation(value = "学生作业-新增", notes = "学生作业")
    @PostMapping(value = "/insertStudentHomeWork")
    public Result<Boolean> insertStudentHomeWork(@RequestBody StudentHomeWorkReq request) {
        return courseResourceService.insertStudentHomeWork(request);
    }

    @ApiOperation(value = "学生作业-批改", notes = "学生作业")
    @GetMapping(value = "/handleStudentHomeWork")
    public Result<Boolean> handleStudentHomeWork(Integer id, String homeWorkPoint) {
        return courseResourceService.handleStudentHomeWork(id, homeWorkPoint);
    }
}
